package org.luxor.cloud.portal.controller;

import io.swagger.annotations.ApiOperation;
import org.luxor.cloud.portal.service.IUserDetailsFeign;
import org.luxor.commons.core.web.data.R;
import org.luxor.commons.security.entity.UserSubject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

/**
 * 基础服务
 *
 * @author Mr.Yan  @date: 2020/9/8
 */
@Controller
public class DefaultController {

    @Resource
    private IUserDetailsFeign userDetailsFeign;

    @ApiIgnore
    @GetMapping("/")
    @ApiOperation(value = "欢迎页")
    public String index() {
        return "index";
    }

    @ApiIgnore
    @GetMapping("/error")
    @ApiOperation(value = "错误页")
    public String error() {
        return "error";
    }

    @GetMapping("/user")
    @ResponseBody
    public R<UserSubject> user() {
        return userDetailsFeign.user();
    }
}
